public class BuggleSort {
    public static void main(String[] args) {
        int[] Sort = {1,4,5,2,3,6,9,8,7};
        int tem = Sort.length;
        int kp = 0;
        int i =0;
        int k = 0;
        for(k = 0;k < tem - 1; k++){
            for(i= 0;i < tem - 1; i++){
                if(Sort[i] > Sort[i+1]){
                    kp = Sort[i];
                    Sort[i] = Sort[i + 1];
                    Sort[i + 1] = kp;
                }if (Sort[i] > Sort[i+1]){
                    return;
                }
            }
        }
        i = 0;
        while (i < tem){
            System.out.print(Sort[i]+" ");
            i++;
        }
    }
}
